<?php
/*
 * Form - Kinh nghiem lam viec
 */
?>
<style>
    .modal {
        width: 727px;
        margin:-250px 0 0 -346px;
    }
    .modal-body {
        max-height: 482px;
        overflow-y: auto;
        padding: 15px;
    }
</style>
<legend id="step3" class='title-field title-jobs mt_20'><i class='icon icon-plus-sign mt_5 icon-white'></i> Kinh nghiệm làm việc</legend>

    <!-- list kinh nghiem lam viec -->
    <?php if (count($model) > 0 && is_array($model)) { ?>
    <div class='info-job'>
        <?php foreach ($model as $key => $item) { ?>
            <div class="row-fluid row-quatrinh itemkn-<?php echo $hid . '-' . $item->id; ?>">
                <div class='span3 ml10'>
                    <b><?php echo $item->tu . ' - ' . $item->den; ?></b>
                </div>
                <div class='span4'>
                    <span class='truong'>
                        <?php echo ucwords($item->congty) . ', ' . $item->tinh_thanhpho; ?>
                    </span>
                    <br />
                    <span class='tp-bc'>
                        <?php echo $item->chucvu; ?>
                    </span>
                    <br />
                    <span class='mota'>
                        <?php echo $item->motacongviec; ?>
                    </span>
                </div>
                <div class='span4 align-right'>
                    <a href="#" class='edit-kn' prop="<?php echo $hid . '-' . $item->id; ?>"><i class="icon-pencil"></i> Sửa</a>
                    <a href="#" class='delete-kn'prop="<?php echo $hid . '-' . $item->id; ?>" ><i class="icon-trash"></i> Xóa</a>
                </div>
            </div>
        <?php } ?>
        </div>
        <div class='row-fluid'>
            <div class='span3'>&nbsp;</div>
            <div class='span9'>
                <a href="#" class='add-kn btn btn-info mt_20' prop="<?php echo $hid . '-' . $item->id; ?>"><i class="icon-pencil"></i> Thêm</a>
            </div>
        </div>
    
    <script>
        $(document).ready(function(){
            $('.modal-footer').remove();
            //add
            $("a.add-kn").click(function(e) {
                $.post('<?php echo Yii::app()->getBaseUrl(true); ?>/ungvien/tintimviec/addkinhnghiemlamviec.html<?php if ($hid != '') {
        echo '?id=' . $hid . '#step3';
    } ?>',{action: 'addkinhnghiemlamviec'},
                function(data){
                    bootbox.alert(data);
                });
                e.preventDefault();
            });
            //edit
            $("a.edit-kn").click(function(e) {
                var _prop = $(this).attr('prop');
                $.post('<?php echo Yii::app()->getBaseUrl(true); ?>/ungvien/tintimviec/editkinhnghiemlamviec?data='+_prop,{action: 'editkinhnghiemlamviec'},
                function(data){
                    bootbox.alert(data);
                });
                e.preventDefault();
            });
            //delete
            $("a.delete-kn").click(function(e) {
                var t = $(this)
                bootbox.confirm('Bạn chắc có muốn xóa!!!','Bỏ qua','Xóa',function(result){
                    if(result){
                        var _prop = t.attr('prop');
                        $.post('<?php echo Yii::app()->getBaseUrl(true); ?>/ungvien/tintimviec/delkinhnghiemlamviec?data='+_prop,{action: 'delkinhnghiemlamviec'},
                        function(data){
                            bootbox.alert(data);
                            $('.itemkn-'+_prop).remove();
                        });
                    }
                });
                e.preventDefault();
            });
                  
        });//end ready
    </script>
    <?php } else { ?>
    <div class='info-job'>
        <?php
        $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
            'id' => 'kinhnghiemlamviec-form',
            'type' => 'horizontal',
            'action' => Yii::app()->getBaseUrl(true) . '/ungvien/tintimviec/' . ($hid != '' && $kid != '') ? '?id=' . $hid . '&kid=' . $kid . '#step3' : '',
            'enableClientValidation' => true,
            //'enableAjaxValidation' => true,
            'clientOptions' => array(
                'validateOnSubmit' => true,
            ),
                ));
        ?>

        <?php echo $form->textFieldRow($model, 'congty', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'tinh_thanhpho', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'chucvu', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'tu', array('class' => 'span2')); ?>
        <?php echo $form->textFieldRow($model, 'den', array('class' => 'span2')); ?>

    <?php echo $form->textAreaRow($model, 'motacongviec', array('class' => 'span7 clearfix')); ?>
        <div class='control-group showsub count'>
            (Mục tiêu nghề nghiệp không được quá <input id='mtcv' value='4000' class='span1' /> kí tự)
        </div>
        <div class='div-row'>
            <label class='mt w150'>&nbsp;</label>
            <p class='nn-row'>
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Thêm' : 'Cập nhật', 'icon' => 'icon-refresh icon-white', 'htmlOptions' => array('id' => 'btn-action'))); ?>
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'reset', 'type' => 'primary', 'label' => 'Bỏ qua', 'icon' => 'icon-remove-sign icon-white', 'htmlOptions' => array('class' => 'close-form'))); ?>
            </p> 
        </div>

        <div class='clearfix'></div>

    <?php $this->endWidget(); ?>
    </div>
<?php } ?>

